//
//  DSFriendsRecommendDetailTabController.m
//  budejie
//
//  Created by tangQiang on 8/27/16.
//  Copyright © 2016 Dason. All rights reserved.
//

#import "DSFriendsRecommendDetailTabController.h"
#import "DSFriendsRecommendDetailTabCell.h"
#import "DSFriendsRecommendDetailModel.h"

@interface DSFriendsRecommendDetailTabController ()
/**
 *  推荐关注数组
 */
@property (strong, nonatomic) NSArray<DSFriendsRecommendDetailModel *> *friendsRecommendDetailModels;
@end

@implementation DSFriendsRecommendDetailTabController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置所有属性
    [self setFriendsRecommendDetailAllAttrbutes];
    
    // 下载数据
    NSDictionary *parameters = @{
                                 @"a" : @"friend_recommend",
                                 @"c" : @"user",
                                 };
    [self downloadRecommendDdataWithDictionary:parameters];
    
    
}

#pragma mark - 重写 set 方法
- (void)setID:(NSString *)ID {
    _ID = ID;
    NSLog(@"%@",ID);
    // 下载数据
    NSDictionary *parameters = @{
                                 @"a" : @"list",
                                 @"c" : @"subscribe",
                                 @"category_id" : _ID,
                                 };
    [self downloadRecommendDdataWithDictionary:parameters];
}


#pragma mark - 设置所有的属性
- (void)setFriendsRecommendDetailAllAttrbutes {
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
}


#pragma mark - 下载数据
- (void)downloadRecommendDdataWithDictionary:(NSDictionary *)parameters {
    [DSFriendsRecommendDetailModel downloadDataWithDictionary:parameters successBlock:^(NSArray<DSFriendsRecommendDetailModel *> *friendsRecommendDetailModels) {
        self.friendsRecommendDetailModels = friendsRecommendDetailModels;
        [self.tableView reloadData];
    } failBlock:^(NSError *error) {
        NSLog(@"error %@", error);
    }];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.friendsRecommendDetailModels.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DSFriendsRecommendDetailTabCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FriendsDetailCell"];
    if (cell == nil) {
        cell = [[DSFriendsRecommendDetailTabCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"FriendsDetailCell"];
    }
    DSFriendsRecommendDetailModel *friendsRecommendDetailModel = self.friendsRecommendDetailModels[indexPath.row];
    cell.friendsRecommendDetailModel = friendsRecommendDetailModel;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}



@end
